﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FACUI.BasicClass
{
     public class Logic : Digit
    {
        private ClassBase _ad1;
        private ClassBase _ad2;
        private ClassBase _ad3;
        private ClassBase _d1;
        private ClassBase _d1Logic;
        private ClassBase _d1Not;
        private ClassBase _d2;
        private ClassBase _d2Logic;
        private ClassBase _d2Not;
        private ClassBase _d3;
        private ClassBase _d3Logic;
        private ClassBase _d3Not;
        private ClassBase _oper;

        public Logic(string name) : base(name, "LOGIC", 1)
        {
            this._d1 = new ClassBase("");
            this._d2 = new ClassBase("");
            this._d3 = new ClassBase("");
            this._d1Not = new ClassBase(false);
            this._d2Not = new ClassBase(false);
            this._d3Not = new ClassBase(false);
            this._d1Logic = new ClassBase(false);
            this._d2Logic = new ClassBase(false);
            this._d3Logic = new ClassBase(false);
            this._ad1 = new ClassBase(0);
            this._ad2 = new ClassBase(0);
            this._ad3 = new ClassBase(0);
            this._oper = new ClassBase(0);
            base.name = name;
            this.d1 = "";
            this.d2 = "";
            this.d3 = "";
            this.d1Not = false;
            this.d2Not = false;
            this.d3Not = false;
            this.d1Logic = false;
            this.d2Logic = false;
            this.d3Logic = false;
            this.oper = 0;
        }

        public override string ToString()
        {
            int num = 0;
            if ((this.d1.Trim() ?? "").Length > 0)
            {
                num++;
            }
            if ((this.d2.Trim() ?? "").Length > 0)
            {
                num++;
            }
            if ((this.d3.Trim() ?? "").Length > 0)
            {
                num++;
            }
            StringBuilder builder = new StringBuilder("");
            builder.Append(base.name).Append(",").Append(this.oper).Append(",").Append(num);
            if ((this.d1.Trim() ?? "").Length > 0)
            {
                builder.Append(",").Append(this.d1.Trim()).Append(this.d1Not ? ";1;" : ";0;").Append(this.d1Logic ? "1;" : "0;").Append(this.ad1);
            }
            if ((this.d2.Trim() ?? "").Length > 0)
            {
                builder.Append(",").Append(this.d2.Trim()).Append(this.d2Not ? ";1;" : ";0;").Append(this.d2Logic ? "1;" : "0;").Append(this.ad2);
            }
            if ((this.d3.Trim() ?? "").Length > 0)
            {
                builder.Append(",").Append(this.d3.Trim()).Append(this.d3Not ? ";1;" : ";0;").Append(this.d3Logic ? "1;" : "0;").Append(this.ad3);
            }
            if ((this.d1.Trim() ?? "").Length == 0)
            {
                builder.Append(",").Append(this.d1.Trim()).Append(this.d1Not ? ";1" : ";0").Append(this.d1Logic ? ";1;65535" : ";0;65535");
            }
            if ((this.d2.Trim() ?? "").Length == 0)
            {
                builder.Append(",").Append(this.d2.Trim()).Append(this.d2Not ? ";1" : ";0").Append(this.d2Logic ? ";1;65535" : ";0;65535");
            }
            if ((this.d3.Trim() ?? "").Length == 0)
            {
                builder.Append(",").Append(this.d3.Trim()).Append(this.d3Not ? ";1" : ";0").Append(this.d3Logic ? ";1;65535" : ";0;65535");
            }
            return builder.ToString();
        }

        public int ad1
        {
            get
            {
                return (int) this._ad1.value;
            }
            set
            {
                this._ad1.value = value;
            }
        }

        public int ad2
        {
            get
            {
                return (int) this._ad2.value;
            }
            set
            {
                this._ad2.value = value;
            }
        }

        public int ad3
        {
            get
            {
                return (int) this._ad3.value;
            }
            set
            {
                this._ad3.value = value;
            }
        }

        public string d1
        {
            get
            {
                return (string) this._d1.value;
            }
            set
            {
                this._d1.value = value;
            }
        }

        public bool d1Logic
        {
            get
            {
                return (bool) this._d1Logic.value;
            }
            set
            {
                this._d1Logic.value = value;
            }
        }

        public bool d1Not
        {
            get
            {
                return (bool) this._d1Not.value;
            }
            set
            {
                this._d1Not.value = value;
            }
        }

        public string d2
        {
            get
            {
                return (string) this._d2.value;
            }
            set
            {
                this._d2.value = value;
            }
        }

        public bool d2Logic
        {
            get
            {
                return (bool) this._d2Logic.value;
            }
            set
            {
                this._d2Logic.value = value;
            }
        }

        public bool d2Not
        {
            get
            {
                return (bool) this._d2Not.value;
            }
            set
            {
                this._d2Not.value = value;
            }
        }

        public string d3
        {
            get
            {
                return (string) this._d3.value;
            }
            set
            {
                this._d3.value = value;
            }
        }

        public bool d3Logic
        {
            get
            {
                return (bool) this._d3Logic.value;
            }
            set
            {
                this._d3Logic.value = value;
            }
        }

        public bool d3Not
        {
            get
            {
                return (bool) this._d3Not.value;
            }
            set
            {
                this._d3Not.value = value;
            }
        }

        public int oper
        {
            get
            {
                return (int) this._oper.value;
            }
            set
            {
                this._oper.value = value;
            }
        }
    }


    public class Digit
    {
        private ClassBase _ad = new ClassBase(0);
        private ClassBase _code = new ClassBase("");
        private ClassBase _desc = new ClassBase("");
        private ClassBase _isLogic = new ClassBase(false);
        private ClassBase _name = new ClassBase("");
        private ClassBase _seq = new ClassBase(0);
        public Logic logic;

        public Digit(string desc, string code, int seq)
        {
            this.name = "";
            this.code = code;
            this.desc = desc;
            this.isLogic = false;
            this.seq = seq;
            this.ad = 0xffff;
            this.logic = null;
        }

        public int ad
        {
            get
            {
                return (int)this._ad.value;
            }
            set
            {
                this._ad.value = value;
            }
        }

        public string code
        {
            get
            {
                return (string)this._code.value;
            }
            set
            {
                this._code.value = value;
            }
        }

        public string desc
        {
            get
            {
                return (string)this._desc.value;
            }
            set
            {
                this._desc.value = value;
            }
        }

        public bool isLogic
        {
            get
            {
                return (bool)this._isLogic.value;
            }
            set
            {
                this._isLogic.value = value;
            }
        }

        public string name
        {
            get
            {
                return (string)this._name.value;
            }
            set
            {
                this._name.value = value;
            }
        }

        public int seq
        {
            get
            {
                return (int)this._seq.value;
            }
            set
            {
                this._seq.value = value;
            }
        }
    }
}

